import {computed} from 'vue';
import dayjs from 'dayjs';

export default (date) => {
 
  return computed(() => {
    if (!date) {
      return [];
    }
    const month = dayjs(date).month() + 1;
    const next = dayjs(date).add(1, 'month').month() + 1;
    const next2 = dayjs(date).add(2, 'month').month() + 1;
    const next3 = dayjs(date).add(3, 'month').month() + 1;
    return  [
      {
        title: '项目名称',
        dataIndex: 'projectName',
        key: 'projectName',
        width: 100,
        fixed: 'left',
      },{
        title: '销售计划',
        children: [
          {
            title: `${month}-剩余`,
            dataIndex: 'salesPlanCurMonth',
            key: 'salesPlanCurMonth',
            width: 100,
          },{
            title: `${next}月`,
            dataIndex: 'salesPlanCurAddOne',
            key: '1',
            width: 100,
          },{
            title: `${next2}月`,
            dataIndex: 'salesPlanCurAddTwo',
            key: '2',
            width: 100,
          },{
            title: `${next3}月`,
            dataIndex: 'salesPlanCurAddThree',
            key: '3',
            width: 100,
          },{
            title: '合计',
            dataIndex: 'sum',
            key: 'sum',
            width: 100,
          },
        ]
      },{
        title: '成品库存',
        dataIndex: 'finishedInventory',
        key: 'finishedInventory',
        width: 100,
      },{
        title: '原料库存',
        dataIndex: 'materialInventory',
        key: 'materialInventory',
        width: 100,
      },{
        title: '库存合计',
        dataIndex: 'inventoryTotal',
        key: 'inventoryTotal',
        width: 100,
      },{
        title: '库存可发货日',
        dataIndex: 'inventoryDeliveryDate',
        key: 'inventoryDeliveryDate',
        width: 100,
      },{
        title: '已采购原料',
        children: [
          {
            title: `${month}月`,
            dataIndex: 'purchasedMaterialCurMonth',
            key: 'purchasedMaterialCurMonth',
            width: 100,
          },{
            title: `${next}月`,
            dataIndex: 'purchasedMaterialCurAddOne',
            key: 'purchasedMaterialCurAddOne',
            width: 100,
          },{
            title: `${next2}月`,
            dataIndex: 'purchasedMaterialCurAddTwo',
            key: 'purchasedMaterialCurAddTwo',
            width: 100,
          },{
            title: `${next3}月`,
            dataIndex: 'purchasedMaterialCurAddThree',
            key: 'purchasedMaterialCurAddThree',
            width: 100,
          },{
            title: '合计',
            dataIndex: 'total',
            key: 'total',
            width: 100,
          },
        ]
      },{
        title: '可发货节点',
        dataIndex: 'shippingDate',
        key: 'shippingDate',
        width: 100,
      }]
  })
}
